package cn.ytnet.shangyun.service.basic.entity;

import org.springframework.stereotype.Component;

import javax.persistence.*;
import java.util.Set;

/**
 * Created by cyongk on 2015/12/8.
 * ClassName：GoodsTotalSortEntity
 * ChineseName：商品总分类
 */
@Component("goodsTotalSortEntity")
@Entity
@Table(name = "T_GoodsTotalSort", schema = "crebas", catalog = "")
public class GoodsTotalSortEntity {
    private String pkTGoodsgotalsortId;
    private String totalsortName;
    private String totalsortPhoneticcode;

    private Set<GoodsSubSortEntity> goodsSubSortEntity;//商品子分类

    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name = "pk_t_goodsgotalsort_id")
    public Set<GoodsSubSortEntity> getGoodsSubSortEntity() {
        return goodsSubSortEntity;
    }

    public void setGoodsSubSortEntity(Set<GoodsSubSortEntity> goodsSubSortEntity) {
        this.goodsSubSortEntity = goodsSubSortEntity;
    }

    @Id
    @Column(name = "pk_t_goodsgotalsort_id", nullable = false, length = 4)
    public String getPkTGoodsgotalsortId() {
        return pkTGoodsgotalsortId;
    }

    public void setPkTGoodsgotalsortId(String pkTGoodsgotalsortId) {
        this.pkTGoodsgotalsortId = pkTGoodsgotalsortId;
    }

    @Basic
    @Column(name = "totalsort_name", nullable = false, length = 30)
    public String getTotalsortName() {
        return totalsortName;
    }

    public void setTotalsortName(String totalsortName) {
        this.totalsortName = totalsortName;
    }

    @Basic
    @Column(name = "totalsort_phoneticcode", nullable = false, length = 30)
    public String getTotalsortPhoneticcode() {
        return totalsortPhoneticcode;
    }

    public void setTotalsortPhoneticcode(String totalsortPhoneticcode) {
        this.totalsortPhoneticcode = totalsortPhoneticcode;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        GoodsTotalSortEntity that = (GoodsTotalSortEntity) o;

        if (pkTGoodsgotalsortId != null ? !pkTGoodsgotalsortId.equals(that.pkTGoodsgotalsortId) : that.pkTGoodsgotalsortId != null)
            return false;
        if (totalsortName != null ? !totalsortName.equals(that.totalsortName) : that.totalsortName != null)
            return false;
        return totalsortPhoneticcode != null ? totalsortPhoneticcode.equals(that.totalsortPhoneticcode) : that.totalsortPhoneticcode == null;

    }

    @Override
    public int hashCode() {
        int result = pkTGoodsgotalsortId != null ? pkTGoodsgotalsortId.hashCode() : 0;
        result = 31 * result + (totalsortName != null ? totalsortName.hashCode() : 0);
        result = 31 * result + (totalsortPhoneticcode != null ? totalsortPhoneticcode.hashCode() : 0);
        return result;
    }
}
